package io.zhoujie.modules.admin.controller;

import io.zhoujie.common.utils.R;
import io.zhoujie.modules.admin.entity.WdQuestEntity;
import io.zhoujie.modules.admin.service.IWdQuestService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 问题管理Controller
 *
 * @author zhoujie
 * @date 2024-03-18
 */
@RestController
@RequestMapping("admin/quest")
public class WdQuestController {
    @Resource
    private IWdQuestService wdQuestService;

    /**
     * 查询问题管理列表
     */
    @GetMapping("/list")
    public R list(WdQuestEntity wdQuestEntity) {
        List<WdQuestEntity> list = wdQuestService.selectWdQuestList(wdQuestEntity);
        return R.ok().put("page", list);
    }

    /**
     * 获取问题管理详细信息
     */
    @GetMapping("/info/{id}")
    public R getInfo(@PathVariable("id") Integer id) {
        return R.ok().put("result", wdQuestService.selectWdQuestById(id));
    }

    /**
     * 新增问题管理
     */
    @PostMapping("/save")
    public R add(@RequestBody WdQuestEntity wdQuestEntity) {
        int i = wdQuestService.insertWdQuest(wdQuestEntity);
        return R.ok().put("result", i);
    }

    /**
     * 修改问题管理
     */
    @PostMapping("/update")
    public R edit(@RequestBody WdQuestEntity wdQuestEntity) {

        int i = wdQuestService.updateWdQuest(wdQuestEntity);
        return R.ok().put("result", i);
    }

    /**
     * 删除问题管理
     */
    @PostMapping("/delete")
    public R remove(@RequestBody Long[] ids) {
        return R.ok().put("result", wdQuestService.deleteWdQuestByIds(ids));
    }
}
